from data import Data
from operation import opera

import pytest


class TestCase(opera):
    @pytest.mark.parametrize('username,passwd,execpt', Data().db())
    def test_login(self, username, passwd, execpt,driver):
        chromeDriver = driver
        if execpt=='个人理财系统' or execpt=='后台管理系统':
            result = self.login_admin(chromeDriver, username, passwd)
        elif execpt=='用户名不存在':
            result=self.login_username(chromeDriver, username, passwd)
        elif execpt=='密码错误':
            result=self.login_password(chromeDriver, username, passwd)
        self.asseerts(execpt, result, chromeDriver)

    @pytest.mark.parametrize('username,passwd,repasswd,expect',Data().db_reg())
    def test_reg(self,username,passwd,repasswd,expect,driver):
        chromeDriver = driver
        if expect=='度小满理财-登录[内测版]':
            result=self.regesiter(chromeDriver,username,passwd,repasswd)
        elif expect=='用户wangwu1已存在':
            result=self.reg_usrfailed(chromeDriver,username,passwd,repasswd)
        elif expect=='两次密码不相同':
            result=self.reg_repwdfailed(chromeDriver,username,passwd,repasswd)
        elif expect=='重复密码为空':
            result=self.reg_repwdempty(chromeDriver,username,passwd,repasswd)
        else:
            result=self.reg_pwdempty(chromeDriver,username,passwd,repasswd)
        self.asseerts(expect,result,chromeDriver)


